<%--
  Created by IntelliJ IDEA.
  User: wangbin
  Date: 2015/3/3
  Time: 9:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../inc/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <%@ include file="../inc/meta.jsp" %>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>新增需求</title>
    <%@ include file="../inc/css.jsp" %>
</head>
<body>

<div id="posts" class="wrapper">

    <%@ include file="../inc/nav.jsp" %>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">新增需求</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <form id="formId" method="post" class="form-horizontal" role="form" enctype="multipart/form-data">

                            <input name="customerId" type="hidden" value="${customerId}">
                            <input name="nextTime" type="hidden" value="">

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >需求描述：</label>
                                <div class="col-sm-4">
                                    <textarea class="form-control" rows="4" name="description" data-rule="required"></textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >下次联系时间：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="nextTime" class="form-control input-append date form_datetime" style="width: 180px;" readonly  value="">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">重要等级：</label>
                                <div class="col-sm-2">
                                    <select class="form-control input-sm" name="grade" data-rule="required">
                                        <option value="">--请选择--</option>
                                        <option value="A">A</option>
                                        <option value="B">B</option>
                                        <option value="C">C</option>
                                        <option value="D">D</option>
                                        <option value="FAIL">战败</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label"></label>
                                <div class="col-sm-6">
                                    <button type="button" onclick="$customer.fn.save()" class="btn btn-primary">保存</button>
                                    <button type="button" class="btn btn-primary" onclick="$customer.fn.back()">返回</button>
                                </div>
                            </div>

                        </form>
                    </div>
                    <!-- /.panel-body -->

                </div>
                <!-- /.panel -->
            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<!-- 配置文件 -->

</body>

<%@ include file="../inc/footer.jsp" %>
<script>
    $customer = {
        v: {
            list: [],
            chart: null,
            dTable: null
        },
        fn: {
            init: function () {
                $('.form_datetime').datetimepicker({
                    language: 'zh-CN',
                    weekStart: 1,
                    todayBtn: 1,
                    autoclose: 1,
                    todayHighlight: 1,
                    minView: 'month',
                    forceParse: 0,
                    showMeridian: false,
                    format: 'yyyy-mm-dd'
                });
            },
            save : function() {
                if(!$("#formId").isValid()) return;

                var nextTime = $("#nextTime").val();

                if(nextTime != ''){
                    var nextDate = Date.parse(new Date(nextTime));
                    $("[name=nextTime]").val(nextDate);
                }

                $("#formId").ajaxSubmit({
                    url : "${contextPath}/admin/customer/saveDemand",
                    type : "POST",
                    success : function(result) {
                        if(result.status == 0) {
                            $customer.fn.back();
                        }else {
                            $leoman.alertMsg(result.msg);
                        }
                    }
                });
            },
            back : function(){
                window.location.href = "${contextPath}/admin/customer/info?id=${customerId}";
            }
        }
    }
    $(function () {
        $customer.fn.init();
    })
</script>

</html>